<?php

function loginfo($info, $logfile = 'log')
{

    $str = PHP_EOL . date("Y-m-d H:i:s", time()) . ' --- ';

    $str .= $info;


    $path =dirname(dirname(dirname(__file__))).'./log/' . $logfile . '.log';
    $fp = fopen($path, 'a+');
    flock($fp, LOCK_EX);// 加锁
    fwrite($fp, date('Y-m-d H:i:s') . "\n" . $info . "\n\n");
    flock($fp, LOCK_UN);// 解锁
    fclose($fp);

}

?>